<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>退货保证金管理</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href="<s:url value="/css/common.css"/>"/>
    <!-- 当前页面样式 END -->
    <script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
    <script type="text/javascript">
    
    function backToSelect(){
    	window.location.href="<%=basePath%>/margin/init.ct";
    }
    	
    function checkSubmit(){
    	
    	var mchtCd = $.trim($("#mchntCd").val());
    	
    	var securityAmt = $.trim($("#securityAmt").val());
    	
    	if(mchtCd == null || mchtCd == ""){
    		alert("商户号不能为空");
    		return false;
    	}
    	
    	if(!/^[0-9]*[1-9][0-9]*$/.test(securityAmt)){
    		alert("保证金总金额输入不规范");
    		return false;
    	}
    		
    	/* if(parseFloat(securityAmt).toString() == "NaN"){
    		alert("保证金总金额输入不规范");
    		return false;
    	}
    	
    	if(securityAmt.lastIndexOf(".") != -1 && securityAmt.substring(securityAmt.indexOf(".")+1).length >2){
        	alert("保证金总额最多只能保留两位小数");
        	return false;
        } */
    	
    	$("#addMargin").attr("action","<%=basePath%>/margin/addMarginSubmit.ct");
		$("#addMargin").submit();
		$(this).attr("disabled",true);
    }
	</script>
</head>
<body>
<s:form id="addMargin" action="" method="post" theme="simple">
	
<table class="tb">
    <tbody>
        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h2">POS收单运营管理平台</div></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h3">新增商户保证金</div></td>
        </tr>
		
		<tr class="tb-line">
			<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">商户号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal"><s:textfield id="mchntCd" name="riskBack.mchntCd" cssClass="queryWidth" /></label>
            </td>
            <td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">终端号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal"><s:textfield id="termId" name="riskBack.termId" cssClass="queryWidth" /></label>
            </td>
		</tr>
        <tr class="tb-line">
        	<td width="12%" style="min-width: 150px" align="right" class="tb-td">
                <div class="tb-h4">保证金总额(元)</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal"><s:textfield id="securityAmt" name="riskBack.securityAmt" cssClass="queryWidth" /></label>
            </td>
         </tr>
         
        <tr class="tb-line">
            <td class="tb-td line-submit" align="right" colspan="4">
                <label class="tb-input-submit">
                    <input type="button" value="保   存" onclick="return checkSubmit();"/>
                </label>
                <label class="tb-input-submit">
                    <input type="button" value="返   回" onclick="return backToSelect();"/>
                </label>
            </td>
        </tr>
    </tbody>
    
</table>

</s:form>

<s:if test="#request.res.flag == true">
		<script language="javascript">
			alert("操作成功！");
			window.location.href="<%=basePath%>/margin/queryMargin.ct";
		</script>
</s:if>
<s:if test="#request.res.flag == false">
	<script language="javascript">
			alert("${res.msg}");
	</script>
</s:if>
</body>
</html>